home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Libraries / TransSkel / Demos / Pascal Demos / Button / Document.p < prev    next >
Encoding:
Text File  |  1994-02-23  |  2.1 KB  |  120 lines  |  [TEXT/PJMM]

  1. unit Document;
  2.  
  3. interface
  4.  
  5.     uses
  6.         TransSkel, ButtonGlobals;
  7.  
  8.  
  9.     procedure SetupDocument;
  10.  
  11. implementation
  12.  
  13.     const
  14.  
  15.         returnKey = chr(13);
  16.         enterKey = chr(3);
  17.  
  18.     var
  19.  
  20.         wind: WindowPtr;
  21.         okBtn: ControlHandle;
  22.         cancelBtn: ControlHandle;
  23.  
  24. {--------------------------------------------------------------------}
  25. { Window handling procedures }
  26. {--------------------------------------------------------------------}
  27.  
  28.  
  29.     procedure Mouse (pt: Point;
  30.                                     t: LongInt;
  31.                                     mods: Integer);
  32.         var
  33.             ctrl: ControlHandle;
  34.             partNo: Integer;
  35.     begin
  36.         partNo := FindControl(pt, wind, ctrl);
  37.         if (partNo <> 0) then
  38.             begin
  39.                 if (partNo = inButton) then
  40.                     begin
  41.                         if (TrackControl(ctrl, pt, nil) <> 0) then
  42.                             begin
  43.                                 { nothing done }
  44.                             end;
  45.                     end;
  46.             end;
  47.     end;
  48.  
  49.  
  50.     procedure Key (c: char;
  51.                                     code: Integer;
  52.                                     mods: Integer);
  53.     begin
  54.         if ((c = returnKey) or (c = enterKey)) then
  55.             begin
  56.                 if (okBtn^^.contrlHilite = normalHilite) then
  57.                     SkelFlashButton(okBtn);
  58.             end;
  59.     end;
  60.  
  61.  
  62.     procedure Update (resized: Boolean);
  63.         var
  64.             wind: WindowPtr;
  65.             r: Rect;
  66.             h: Integer;
  67.     begin
  68.         GetPort(wind);
  69.  
  70.         r := wind^.portRect;
  71.         EraseRect(r);
  72.         DrawControls(wind);
  73.         SkelDrawButtonOutline(okBtn);
  74.     end;
  75.  
  76.  
  77.     procedure Activate (active: Boolean);
  78.         var
  79.             hilite: Integer;
  80.     begin
  81.         if (active) then
  82.             hilite := normalHilite
  83.         else
  84.             hilite := dimHilite;
  85.         HiliteControl(okBtn, hilite);
  86.         SkelDrawButtonOutline(okBtn);
  87.         HiliteControl(cancelBtn, hilite);
  88.     end;
  89.  
  90.  
  91.     procedure Clobber;
  92.         var
  93.             wind: WindowPtr;
  94.     begin
  95.         GetPort(wind);
  96.         HideWindow(wind);
  97.         DisposeWindow(wind);
  98.     end;
  99.  
  100.  
  101.     procedure SetupDocument;
  102.         var
  103.             r: Rect;
  104.             ignore: Boolean;
  105.     begin
  106.  
  107.         if (SkelQuery(skelQHasColorQD) <> 0) then
  108.             wind := GetNewCWindow(windRes, nil, WindowPtr(-1))
  109.         else
  110.             wind := GetNewWindow(windRes, nil, WindowPtr(-1));
  111.         ignore := SkelWindow(wind, @Mouse, @Key, @Update, @Activate, nil, @Clobber, nil, false);
  112.         SetRect(r, 10, 20, 80, 40);
  113.         cancelBtn := NewControl(wind, r, 'Cancel', true, 0, 0, 1, pushButProc, 0);
  114.         OffsetRect(r, 80, 0);
  115.         okBtn := NewControl(wind, r, 'OK', true, 0, 0, 1, pushButProc, 0);
  116.  
  117.         ShowWindow(wind);
  118.     end;
  119.  
  120. end.